//
// Created by 11510 on 2024/6/11.
//
#include <iostream>
using namespace std;

// 复数
class Complex{
private:
    int _real;
    int _image;


public:
    Complex(int real, int image):_real(real), _image(image){}

//    NOTICE: 这里返回时候是调用拷贝构造，不是返回了栈内存
    /**
     * 成员函数方式进行重载
     * @param rhs
     * @return
     */
    Complex operator+(const Complex &rhs){
        return Complex(_real + rhs._real, _image + rhs._image);
    }
    void print() const{
        cout << _real << " + " << _image << "i" << endl;
    }

};


void test0(){
    Complex cx1(1, 2);
    Complex cx2(3, 4);

    Complex cx3 = cx1 + cx2;
    cx3.print();
}


int main() {
    test0();
    return 0;
}